#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 3009; //100005

int things[N];
int sum[N];
int n,m,ans = INT_MAX;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for(int i=1;i<=n;i++)
	{
		cin >> things[i];
		sum[i] = sum[i-1]+things[i];
	}	
	for(int i=n;i>=m;i--)
	{
		ans = min(ans,sum[i]-sum[i-m]);
	}
	cout << ans;
	return 0;
}
